var host = process.env.HOST;

/**
 * 获取微信session_key
 * @param {*} data 
 */
export const getSessionCode = (data) => {
	return uni.request({
		url: host+"/api/Wechat/getSessionCode",
		method: 'GET',
		data
	})
} 

/**
 * 获取企业微信session_key
 * @param {*} data 
 */
export const getSessionCode2= (data) => {
	return uni.request({
		url: host+"/api/Wechat/corpSessionCode",
		method: 'GET',
		data
	})
}

/**
 * 获取微信系统信息
 * @param {*} data 
 */
export const  getSystemInfo =  (data) => {	
	return new Promise((resolve, reject) => {
		wx.getSystemInfo({
			success (res) {			
				/*console.log(res.model)
				console.log(res.pixelRatio)
				console.log(res.windowWidth)
				console.log(res.windowHeight)
				console.log(res.language)
				console.log(res.version)
				console.log(res.platform)
				console.log(res.environment)*/
				resolve(res);
			},
			fail(err) {
				console.log('获取微信基础信息失败！');
				reject(err);
			}
		});
	});
}


/**
 * 企业微信登录，获取code
 * @param {*} data 
 */
export const  wxqyLogin =  (data) => {	
	return new Promise((resolve, reject) => {
		wx.qy.login({
			success: function(res) {
				if (res.code) {
					resolve(res);
				} else {
					console.log('获取code失败！' + res.errMsg)
				}
			},
			fail(err) {
				console.log('企业微信登录失败！');
				reject(err);
			}
		});
	});
}








